package cn.bugio.note.controller.content;

import cn.bugio.note.auth.CheckLogin;
import cn.bugio.note.common.domain.dto.ShareDTO;
import cn.bugio.note.common.dubbo.TestService;
import cn.bugio.note.common.vo.ServerResponse;
import cn.bugio.note.sentinel.GlobalSentinelFallback;
import cn.bugio.note.service.content.ShareService;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Vincent Vic
 * @version 1.0
 * @Description
 * @since 2021/2/16
 */

@RestController
@RequestMapping("/shares/")
@Slf4j
public class ShareController {

    @Autowired
    private ShareService shareService;

    @GetMapping("{id}")
    @ResponseBody
    @CheckLogin
    public ServerResponse<ShareDTO> findById(@PathVariable Integer id){
        log.info("请求id: {}",id);
        return shareService.findById(id);
    }

    @Reference
    private TestService testService;

    @GetMapping("test")
    @SentinelResource(value = "testOrderDubbo",fallbackClass = GlobalSentinelFallback.class)
    public String testOrderDubbo(String msg) {
        log.info("msg : {}",msg);
        return testService.test(msg, "payment访问order模块");
    }

}
